import React, { memo } from 'react';
import { withRouter, router } from 'umi';
import AuthComponent from '@/utils/auth/AuthComponent';

import { Icon } from '@/pages/Recruitment/components';

function OperateButton({ url, code, query, iconType, title, jumpType, ...rest }) {
    // React.useEffect(() => {
    //     console.log('OperateButton', url, code, query, iconType, title);
    // }, []);
    const { onClick } = rest;
    const handleJump = () => {
        if (jumpType === 1) {
            history.push({
                pathname: url,
                query
            });
        } else {
            history.push({
                pathname: url,
                query,
                state: { tabRoute: true }
            });
        }
    };
    return (
        <AuthComponent code={code}>
            <Icon
                title={title}
                type={iconType}
                style={{ cursor: 'pointer', fontSize: 22 }}
                {...rest}
                onClick={onClick || handleJump}
            />
        </AuthComponent>
    );
}
export default withRouter(memo(OperateButton));
